package com.vint.leetcode;

import com.vint.common.TreeNode;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Stack;

/*
 * 1. done
 * 2. easy
 */
public class Leetcode108 {
	public TreeNode sortedArrayToBST(int[] nums) {
		return addNode(nums,0,nums.length-1);
	}
	public TreeNode addNode(int[] nums, int start, int end) {
		if (start == end) {
			return new TreeNode(nums[start]);
		}
		if(end < start) return null;
		int mid = (start + end) / 2;
		TreeNode root = new TreeNode(nums[mid]);
		root.left = addNode(nums, start, mid -1);
		root.right = addNode(nums, mid + 1,end);
		return root;
	}
}
